package com.szxy.plugin;

import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.policy.DynamicTableRenderPolicy;
import com.deepoove.poi.policy.MiniTableRenderPolicy;
import org.apache.poi.xwpf.usermodel.XWPFTable;

import java.util.List;

/**
 * @Author: zwz
 * @Date:2020/7/28 14:45
 * @Description:com.szxy.plugin
 * @Version:1.0
 * 公共插件 - 从表格第三行开始插入数据
 **/
public class TwoCommonTablePolicy extends DynamicTableRenderPolicy {

    /**
     * 跳过的行数
     */
    public static final int SKIP_ROWS = 2;

    @Override
    public void render(XWPFTable table, Object data) {
        // 数据校验
        if(null == data)  return;

        List<RowRenderData> allSocailDataList = (List<RowRenderData>) data;

        if (null != allSocailDataList) {
            for (int i = 0; i < allSocailDataList.size(); i++) {
                MiniTableRenderPolicy.renderRow(table, i+ SKIP_ROWS, allSocailDataList.get(i));
            }
        }
    }
}
